<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "shbb_product_sale".
 *
 * @property integer $id
 * @property string $purchase_type
 * @property string $purchase_info
 * @property string $comment
 * @property integer $audit_account_id
 * @property integer $product_id
 *
 * @property User $auditAccount
 * @property ShbbProduct $product
 */
class ProductSale extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'shbb_product_sale';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['purchase_info'], 'string'],
            [['audit_account_id', 'product_id'], 'integer'],
            [['purchase_type', 'comment'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'purchase_type' => 'Purchase Type',
            'purchase_info' => 'Purchase Info',
            'comment' => 'Comment',
            'audit_account_id' => 'Audit Account ID',
            'product_id' => 'Product ID',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getAuditAccount()
    {
        return $this->hasOne(User::className(), ['id' => 'audit_account_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getProduct()
    {
        return $this->hasOne(ShbbProduct::className(), ['id' => 'product_id']);
    }
}
